<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <meta name="baidu-site-verification" content="code-oLqr5o013S">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"shaojunying.github.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":true,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="网络模型五层网络模型分为应用层、传输层、网络层、数据链路层、物理层。 现实中的网络模型将五层网络模型中的数据链路层和物理层合并为网络接口层 OSI七层网络模型将五层网络模型中的应用层拆分为会话层、表示层、应用层。 各层的作用 物理层。将01比特从一台节点通过物理链路传递到另一个节点 数据链路层。将数据分组从一个节点传递到另一个节点，同时提供差错检测和纠正的功能。 网络层。将数据包从一台主机传递到另">
<meta property="og:type" content="article">
<meta property="og:title" content="《计算机网络》学习笔记">
<meta property="og:url" content="https://shaojunying.github.io/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/index.html">
<meta property="og:site_name" content="Shaojunying&#39;s Blog">
<meta property="og:description" content="网络模型五层网络模型分为应用层、传输层、网络层、数据链路层、物理层。 现实中的网络模型将五层网络模型中的数据链路层和物理层合并为网络接口层 OSI七层网络模型将五层网络模型中的应用层拆分为会话层、表示层、应用层。 各层的作用 物理层。将01比特从一台节点通过物理链路传递到另一个节点 数据链路层。将数据分组从一个节点传递到另一个节点，同时提供差错检测和纠正的功能。 网络层。将数据包从一台主机传递到另">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://shaojunying.github.io/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/1.png">
<meta property="article:published_time" content="2021-04-04T06:03:37.000Z">
<meta property="article:modified_time" content="2021-04-04T06:07:31.049Z">
<meta property="article:author" content="邵俊颖">
<meta property="article:tag" content="计算机网络">
<meta property="article:tag" content="校招">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://shaojunying.github.io/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/1.png">

<link rel="canonical" href="https://shaojunying.github.io/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>《计算机网络》学习笔记 | Shaojunying's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="Shaojunying's Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Shaojunying's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">35</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">55</span></a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <a href="https://github.com/shaojunying" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          《计算机网络》学习笔记
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-04-04 14:03:37 / 修改时间：14:07:31" itemprop="dateCreated datePublished" datetime="2021-04-04T14:03:37+08:00">2021-04-04</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="网络模型"><a href="#网络模型" class="headerlink" title="网络模型"></a>网络模型</h1><h2 id="五层网络模型"><a href="#五层网络模型" class="headerlink" title="五层网络模型"></a>五层网络模型</h2><p>分为应用层、传输层、网络层、数据链路层、物理层。</p>
<h2 id="现实中的网络模型"><a href="#现实中的网络模型" class="headerlink" title="现实中的网络模型"></a>现实中的网络模型</h2><p>将<strong>五层网络模型</strong>中的数据链路层和物理层合并为网络接口层</p>
<h2 id="OSI七层网络模型"><a href="#OSI七层网络模型" class="headerlink" title="OSI七层网络模型"></a>OSI七层网络模型</h2><p>将<strong>五层网络模型</strong>中的应用层拆分为会话层、表示层、应用层。</p>
<h1 id="各层的作用"><a href="#各层的作用" class="headerlink" title="各层的作用"></a>各层的作用</h1><ul>
<li><strong>物理层</strong>。将01比特从一台节点通过物理链路传递到另一个节点</li>
<li><strong>数据链路层</strong>。将数据分组从一个节点传递到另一个节点，同时提供差错检测和纠正的功能。</li>
<li><strong>网络层</strong>。将数据包从一台主机传递到另一台主机，提供的是一种尽力而为的服务。</li>
<li><strong>传输层</strong>。提供应用进程之间的数据传输服务。</li>
<li><strong>应用层</strong>。使用一些具体的协议传输数据。这些协议如HTTP、DNS、FTP、SMTP等。</li>
</ul>
<h1 id="应用层"><a href="#应用层" class="headerlink" title="应用层"></a>应用层</h1><h2 id="SMTP和HTTP"><a href="#SMTP和HTTP" class="headerlink" title="SMTP和HTTP"></a>SMTP和HTTP</h2><p>HTTP是一个”拉”协议。客户端发起请求之后服务端发送响应。</p>
<p>SMTP是一个“推”协议。发送方mail服务器直接将邮件推到接收方服务器上。</p>
<h2 id="DNS工作原理"><a href="#DNS工作原理" class="headerlink" title="DNS工作原理"></a>DNS工作原理</h2><p>每个ISP通常都有一个本地DNS服务器</p>
<ol>
<li>主机想要获取一个域名对应的IP地址，则向本地DNS服务器发送请求。</li>
<li>本地DNS依次向根服务器以及各级服务器发送请求获取域名对应的IP地址（如果已有缓存则不用发送请求）。</li>
</ol>
<p>其中主机向本地DNS服务器发送请求是<strong>递归查询</strong>，本地DNS服务器向其他服务器发送请求是<strong>迭代查询</strong>。</p>
<h1 id="运输层"><a href="#运输层" class="headerlink" title="运输层"></a>运输层</h1><h2 id="运输层提供的基本服务"><a href="#运输层提供的基本服务" class="headerlink" title="运输层提供的基本服务"></a>运输层提供的基本服务</h2><ul>
<li>数据交付</li>
<li>差错检测</li>
</ul>
<p>这也是UDP提供的仅有的两种服务。</p>
<h2 id="TCP提供的额外的服务"><a href="#TCP提供的额外的服务" class="headerlink" title="TCP提供的额外的服务"></a>TCP提供的额外的服务</h2><ul>
<li>可靠数据传输（包括序号、确认、定时器、流量控制）</li>
<li>拥塞控制</li>
</ul>
<h2 id="TCP的演化"><a href="#TCP的演化" class="headerlink" title="TCP的演化"></a>TCP的演化</h2><h3 id="停等协议（每次只发一条数据，确认后发送下一条数据）"><a href="#停等协议（每次只发一条数据，确认后发送下一条数据）" class="headerlink" title="停等协议（每次只发一条数据，确认后发送下一条数据）"></a>停等协议（每次只发一条数据，确认后发送下一条数据）</h3><ol>
<li>为了解决数据包出错的问题，引入<strong>确认</strong>（肯定确认和否定确认）机制。</li>
<li>确认帧可能受损，如果收到一个损坏的帧，就重发数据包。为了区分是重传还是新数据包，引入<strong>序号</strong>机制。</li>
<li>为了解决丢包问题，引入<strong>定时器</strong>机制。</li>
</ol>
<h3 id="流水线可靠数据传输协议"><a href="#流水线可靠数据传输协议" class="headerlink" title="流水线可靠数据传输协议"></a>流水线可靠数据传输协议</h3><ul>
<li><strong>回退N步。</strong><ul>
<li>采用<strong>累计确认</strong></li>
<li>超时时发送方重传所有未确认分组</li>
</ul>
</li>
<li><strong>选择重传。</strong><ul>
<li>接收方缓存接受到的失序分组</li>
<li>接收到[recv_base - N, recv_base - 1] 和[recv_base, recv_base + N - 1]都需要发送ACK</li>
<li>窗口大小应该小于等于序号区间的一半。</li>
</ul>
</li>
</ul>
<h2 id="TCP的可靠数据传输"><a href="#TCP的可靠数据传输" class="headerlink" title="TCP的可靠数据传输"></a>TCP的可靠数据传输</h2><ul>
<li>累计确认。（发送确认帧时说明之前的帧都已收到）</li>
<li>超时间隔加倍。（超时的时候定时器的间隔加倍，收到ACK后会重新计算超时间隔）</li>
<li>快速重传：如果收到失序的数据，冗余发送3个ACK</li>
</ul>
<h2 id="TCP：回退N-or-选择重传"><a href="#TCP：回退N-or-选择重传" class="headerlink" title="TCP：回退N or 选择重传"></a>TCP：回退N or 选择重传</h2><p>TCP算是两者的结合体，使用累计确认的方法，但是接收方会缓存失序的帧。</p>
<h2 id="TCP的流量控制"><a href="#TCP的流量控制" class="headerlink" title="TCP的流量控制"></a>TCP的流量控制</h2><ul>
<li><strong>接收窗口大小 = 缓冲区大小 - 已接收但是没有被上层使用的数据</strong></li>
<li>为了让发送方不会淹没接受方，发送方的<strong>已发送未确认数据大小应该≤接收窗口大小</strong></li>
</ul>
<h2 id="TCP的拥塞控制"><a href="#TCP的拥塞控制" class="headerlink" title="TCP的拥塞控制"></a>TCP的拥塞控制</h2><p><strong>cwnd</strong>表示拥塞窗口大小，MSS为TCP的最大分段大小。</p>
<p><strong>已发送未确认数据大小应该≤接收窗口大小 并且 ≤ 拥塞窗口大小</strong></p>
<ul>
<li>慢启动。每次收到一个ACK，cwnd变为原来的2次方，超时则恢复为1</li>
<li>拥塞避免。每次收到ACK只增加（MSS（MSS/cwnd））</li>
<li>快速恢复。每次收到冗余ACK只增加MSS</li>
</ul>
<p>超时的时候threshold被设置为cwnd/2</p>
<h3 id="转化关系"><a href="#转化关系" class="headerlink" title="转化关系"></a>转化关系</h3><p><img src="1.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/96c6cefd-9e62-4cc9-a60b-578e5c358ab8/Untitled.png"></p>
<h1 id="网络层（数据层面）"><a href="#网络层（数据层面）" class="headerlink" title="网络层（数据层面）"></a>网络层（数据层面）</h1><h2 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h2><ul>
<li>网络层提供两种功能：<ul>
<li><strong>转发。</strong>当一个分组到达网络层时，网络层应该将它移动到合适的出口。</li>
<li><strong>路由选择。</strong>决定分组到目的地应该走的路径。</li>
</ul>
</li>
<li>网络层提供一种尽力而为的交付模式</li>
</ul>
<h2 id="路由器的工作原理"><a href="#路由器的工作原理" class="headerlink" title="路由器的工作原理"></a>路由器的工作原理</h2><ul>
<li>路由器匹配时采用<strong>最长前缀匹配原则</strong>从而进行路由选择</li>
<li>丢包问题<ul>
<li><strong>输入队列丢包。</strong>不同输入队列的分组准备前往同一个输出队列（交换的速度<strong>没有足够快</strong>），第一个包后面的包将会排队，进而在队列满的时候将会发生丢包。</li>
<li><strong>输出队列丢包</strong>。如果交换速度<strong>足够快</strong>，多个输入收到的包准备前往相同的输出口，输出队列将会排队，进而发生丢包</li>
</ul>
</li>
</ul>
<h2 id="IPv4"><a href="#IPv4" class="headerlink" title="IPv4"></a>IPv4</h2><h3 id="报文格式"><a href="#报文格式" class="headerlink" title="报文格式"></a>报文格式</h3><p>数据包格式</p>
<p>版本 首部长度 服务类型 数据包长度</p>
<p>16位标识         标志位 13位片偏移</p>
<p>寿命 上层协议 校验和</p>
<p>源IP</p>
<p>目的IP</p>
<ul>
<li><strong>服务类型</strong>可用来区分实时流量和非实时流量</li>
<li><strong>标识 标志 片偏移</strong>：数据链路层有MTU最大传输单元，如果IP长度超过MTU，路由器需要将其拆分。（到目的地再被组装）。</li>
<li><strong>首部校验和</strong>：将首部每两个字节看成一个数，相加的和作为校验和。(TCP的校验和计算整个数据报，而IP的校验和只计算首部)</li>
<li><strong>上层协议</strong>：目的地根据该字段选择将数据交给哪一层。</li>
</ul>
<h2 id="DHCP（动态主机配置协议）"><a href="#DHCP（动态主机配置协议）" class="headerlink" title="DHCP（动态主机配置协议）"></a>DHCP（动态主机配置协议）</h2><p>DHCP是使用UDP进行传递的。</p>
<ol>
<li>客户广播一条ICMP查询报文，获取可用的IP地址（源IP为0.0.0.0，目标IP为255.255.255.255）</li>
<li>ICMP分配一个IP，并生成并广播ICMP响应报文（源IP为服务器IP，目标IP为255.255.255.255）（可能客户所在子网有多个ICMP服务器，所以客户需要选择一个并进行确认）。</li>
<li>客户端广播一条请求报文，请求将某一IP设置为自己的IP。</li>
<li>服务端响应ACK报文，客户端将该IP作为自己的IP。</li>
</ol>
<h2 id="NAT（本地地址转换）"><a href="#NAT（本地地址转换）" class="headerlink" title="NAT（本地地址转换）"></a>NAT（本地地址转换）</h2><p>路由器维护一个NAT表，分别存储局域网IP：端口和广域网IP：端口的对应关系，在数据包进出的时候对IP进行转换，进而完成使用一个IP地址完成最高6万（取决于端口的数量）个用户的联网工作。</p>
<h2 id="IPv6"><a href="#IPv6" class="headerlink" title="IPv6"></a>IPv6</h2><p>IPv4对比IPv6</p>
<ul>
<li><strong>分片字段被删除。</strong>如果IP分组过大，路由器将向源主机发送一个”分组过大”ICMP报文。分片工作留给源主机完成。</li>
<li>首部校验和被删除。每次TTL发生变化，都需要重新计算校验和，工作量较大，因此在IPv6中该字段被删除。</li>
</ul>
<h1 id="网络层（控制层面）"><a href="#网络层（控制层面）" class="headerlink" title="网络层（控制层面）"></a>网络层（控制层面）</h1><h2 id="路由选择算法"><a href="#路由选择算法" class="headerlink" title="路由选择算法"></a>路由选择算法</h2><h3 id="链路状态协议（集中式）"><a href="#链路状态协议（集中式）" class="headerlink" title="链路状态协议（集中式）"></a>链路状态协议（集中式）</h3><p>每个节点维护整个子网的链路状态，进而计算出源节点到目标节点的花销，使用Dijkstra算法。</p>
<h3 id="距离矢量协议（分布式）"><a href="#距离矢量协议（分布式）" class="headerlink" title="距离矢量协议（分布式）"></a>距离矢量协议（分布式）</h3><p>每个节点向直接邻居发送当前到各个节点的最短路径，同时接受邻居的信息并更新，直到自己的各最短路径不再发生变化。</p>
<h2 id="ICMP（互联网控制信息报文）"><a href="#ICMP（互联网控制信息报文）" class="headerlink" title="ICMP（互联网控制信息报文）"></a>ICMP（互联网控制信息报文）</h2><p>ping和traceroute都使用该报文</p>
<h1 id="数据链路层"><a href="#数据链路层" class="headerlink" title="数据链路层"></a>数据链路层</h1><p>通过单一信道，将数据从一个节点移动到相邻的节点。</p>
<h2 id="差错检测和纠正"><a href="#差错检测和纠正" class="headerlink" title="差错检测和纠正"></a>差错检测和纠正</h2><ul>
<li>奇偶校验</li>
<li>循环冗余校验</li>
</ul>
<h2 id="可靠重传"><a href="#可靠重传" class="headerlink" title="可靠重传"></a>可靠重传</h2><p>数据链路层的可靠重传保证了在链路上纠错，而不是传输层或应用层的端到端重传。</p>
<h2 id="多路访问控制协议"><a href="#多路访问控制协议" class="headerlink" title="多路访问控制协议"></a>多路访问控制协议</h2><h3 id="信道划分协议"><a href="#信道划分协议" class="headerlink" title="信道划分协议"></a>信道划分协议</h3><p>时分复用 频分复用</p>
<h3 id="随机接入协议"><a href="#随机接入协议" class="headerlink" title="随机接入协议"></a>随机接入协议</h3><p>纯ALOHA、时隙ALOHA、CSMA、CSMA/CD</p>
<h3 id="轮流协议"><a href="#轮流协议" class="headerlink" title="轮流协议"></a>轮流协议</h3><h2 id="ARP协议-地址解析协议"><a href="#ARP协议-地址解析协议" class="headerlink" title="ARP协议(地址解析协议)"></a>ARP协议(地址解析协议)</h2><p>每个主机上都会维护一个ARP表，里面存储子网内的IP和MAC地址的对应关系。想把数据传递到子网内的下一个节点时，就将目标节点的MAC地址设置为目标MAC地址。</p>
<p>MAC地址通过查询ARP获取，如果ARP表中不存在，则构造一个ARP分组并在子网内广播。目标主机收到分组之后返回自己的MAC地址。（使用的是MAC广播地址，全是F）</p>

    </div>

    
    
    

      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" rel="tag"><i class="fa fa-tag"></i> 计算机网络</a>
              <a href="/tags/%E6%A0%A1%E6%8B%9B/" rel="tag"><i class="fa fa-tag"></i> 校招</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/02/07/Java%E4%B8%ADHashMap%E4%B8%BA%E4%BB%80%E4%B9%88%E7%BA%BF%E7%A8%8B%E4%B8%8D%E5%AE%89%E5%85%A8/" rel="prev" title="Java中HashMap为什么线程不安全">
      <i class="fa fa-chevron-left"></i> Java中HashMap为什么线程不安全
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/04/04/Spring%E8%A7%A3%E5%86%B3%E5%BE%AA%E7%8E%AF%E4%BE%9D%E8%B5%96/" rel="next" title="Spring解决循环依赖">
      Spring解决循环依赖 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BD%91%E7%BB%9C%E6%A8%A1%E5%9E%8B"><span class="nav-number">1.</span> <span class="nav-text">网络模型</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%94%E5%B1%82%E7%BD%91%E7%BB%9C%E6%A8%A1%E5%9E%8B"><span class="nav-number">1.1.</span> <span class="nav-text">五层网络模型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%8E%B0%E5%AE%9E%E4%B8%AD%E7%9A%84%E7%BD%91%E7%BB%9C%E6%A8%A1%E5%9E%8B"><span class="nav-number">1.2.</span> <span class="nav-text">现实中的网络模型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#OSI%E4%B8%83%E5%B1%82%E7%BD%91%E7%BB%9C%E6%A8%A1%E5%9E%8B"><span class="nav-number">1.3.</span> <span class="nav-text">OSI七层网络模型</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%90%84%E5%B1%82%E7%9A%84%E4%BD%9C%E7%94%A8"><span class="nav-number">2.</span> <span class="nav-text">各层的作用</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BA%94%E7%94%A8%E5%B1%82"><span class="nav-number">3.</span> <span class="nav-text">应用层</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#SMTP%E5%92%8CHTTP"><span class="nav-number">3.1.</span> <span class="nav-text">SMTP和HTTP</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DNS%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86"><span class="nav-number">3.2.</span> <span class="nav-text">DNS工作原理</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%BF%90%E8%BE%93%E5%B1%82"><span class="nav-number">4.</span> <span class="nav-text">运输层</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%BF%90%E8%BE%93%E5%B1%82%E6%8F%90%E4%BE%9B%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%9C%8D%E5%8A%A1"><span class="nav-number">4.1.</span> <span class="nav-text">运输层提供的基本服务</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TCP%E6%8F%90%E4%BE%9B%E7%9A%84%E9%A2%9D%E5%A4%96%E7%9A%84%E6%9C%8D%E5%8A%A1"><span class="nav-number">4.2.</span> <span class="nav-text">TCP提供的额外的服务</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TCP%E7%9A%84%E6%BC%94%E5%8C%96"><span class="nav-number">4.3.</span> <span class="nav-text">TCP的演化</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%81%9C%E7%AD%89%E5%8D%8F%E8%AE%AE%EF%BC%88%E6%AF%8F%E6%AC%A1%E5%8F%AA%E5%8F%91%E4%B8%80%E6%9D%A1%E6%95%B0%E6%8D%AE%EF%BC%8C%E7%A1%AE%E8%AE%A4%E5%90%8E%E5%8F%91%E9%80%81%E4%B8%8B%E4%B8%80%E6%9D%A1%E6%95%B0%E6%8D%AE%EF%BC%89"><span class="nav-number">4.3.1.</span> <span class="nav-text">停等协议（每次只发一条数据，确认后发送下一条数据）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B5%81%E6%B0%B4%E7%BA%BF%E5%8F%AF%E9%9D%A0%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE"><span class="nav-number">4.3.2.</span> <span class="nav-text">流水线可靠数据传输协议</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TCP%E7%9A%84%E5%8F%AF%E9%9D%A0%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93"><span class="nav-number">4.4.</span> <span class="nav-text">TCP的可靠数据传输</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TCP%EF%BC%9A%E5%9B%9E%E9%80%80N-or-%E9%80%89%E6%8B%A9%E9%87%8D%E4%BC%A0"><span class="nav-number">4.5.</span> <span class="nav-text">TCP：回退N or 选择重传</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TCP%E7%9A%84%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6"><span class="nav-number">4.6.</span> <span class="nav-text">TCP的流量控制</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#TCP%E7%9A%84%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6"><span class="nav-number">4.7.</span> <span class="nav-text">TCP的拥塞控制</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%BD%AC%E5%8C%96%E5%85%B3%E7%B3%BB"><span class="nav-number">4.7.1.</span> <span class="nav-text">转化关系</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BD%91%E7%BB%9C%E5%B1%82%EF%BC%88%E6%95%B0%E6%8D%AE%E5%B1%82%E9%9D%A2%EF%BC%89"><span class="nav-number">5.</span> <span class="nav-text">网络层（数据层面）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A6%82%E8%BF%B0"><span class="nav-number">5.1.</span> <span class="nav-text">概述</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%AF%E7%94%B1%E5%99%A8%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86"><span class="nav-number">5.2.</span> <span class="nav-text">路由器的工作原理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#IPv4"><span class="nav-number">5.3.</span> <span class="nav-text">IPv4</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8A%A5%E6%96%87%E6%A0%BC%E5%BC%8F"><span class="nav-number">5.3.1.</span> <span class="nav-text">报文格式</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DHCP%EF%BC%88%E5%8A%A8%E6%80%81%E4%B8%BB%E6%9C%BA%E9%85%8D%E7%BD%AE%E5%8D%8F%E8%AE%AE%EF%BC%89"><span class="nav-number">5.4.</span> <span class="nav-text">DHCP（动态主机配置协议）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#NAT%EF%BC%88%E6%9C%AC%E5%9C%B0%E5%9C%B0%E5%9D%80%E8%BD%AC%E6%8D%A2%EF%BC%89"><span class="nav-number">5.5.</span> <span class="nav-text">NAT（本地地址转换）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#IPv6"><span class="nav-number">5.6.</span> <span class="nav-text">IPv6</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BD%91%E7%BB%9C%E5%B1%82%EF%BC%88%E6%8E%A7%E5%88%B6%E5%B1%82%E9%9D%A2%EF%BC%89"><span class="nav-number">6.</span> <span class="nav-text">网络层（控制层面）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%B7%AF%E7%94%B1%E9%80%89%E6%8B%A9%E7%AE%97%E6%B3%95"><span class="nav-number">6.1.</span> <span class="nav-text">路由选择算法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%93%BE%E8%B7%AF%E7%8A%B6%E6%80%81%E5%8D%8F%E8%AE%AE%EF%BC%88%E9%9B%86%E4%B8%AD%E5%BC%8F%EF%BC%89"><span class="nav-number">6.1.1.</span> <span class="nav-text">链路状态协议（集中式）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%B7%9D%E7%A6%BB%E7%9F%A2%E9%87%8F%E5%8D%8F%E8%AE%AE%EF%BC%88%E5%88%86%E5%B8%83%E5%BC%8F%EF%BC%89"><span class="nav-number">6.1.2.</span> <span class="nav-text">距离矢量协议（分布式）</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ICMP%EF%BC%88%E4%BA%92%E8%81%94%E7%BD%91%E6%8E%A7%E5%88%B6%E4%BF%A1%E6%81%AF%E6%8A%A5%E6%96%87%EF%BC%89"><span class="nav-number">6.2.</span> <span class="nav-text">ICMP（互联网控制信息报文）</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82"><span class="nav-number">7.</span> <span class="nav-text">数据链路层</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B7%AE%E9%94%99%E6%A3%80%E6%B5%8B%E5%92%8C%E7%BA%A0%E6%AD%A3"><span class="nav-number">7.1.</span> <span class="nav-text">差错检测和纠正</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%AF%E9%9D%A0%E9%87%8D%E4%BC%A0"><span class="nav-number">7.2.</span> <span class="nav-text">可靠重传</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%A4%9A%E8%B7%AF%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6%E5%8D%8F%E8%AE%AE"><span class="nav-number">7.3.</span> <span class="nav-text">多路访问控制协议</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BF%A1%E9%81%93%E5%88%92%E5%88%86%E5%8D%8F%E8%AE%AE"><span class="nav-number">7.3.1.</span> <span class="nav-text">信道划分协议</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%9A%8F%E6%9C%BA%E6%8E%A5%E5%85%A5%E5%8D%8F%E8%AE%AE"><span class="nav-number">7.3.2.</span> <span class="nav-text">随机接入协议</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%BD%AE%E6%B5%81%E5%8D%8F%E8%AE%AE"><span class="nav-number">7.3.3.</span> <span class="nav-text">轮流协议</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ARP%E5%8D%8F%E8%AE%AE-%E5%9C%B0%E5%9D%80%E8%A7%A3%E6%9E%90%E5%8D%8F%E8%AE%AE"><span class="nav-number">7.4.</span> <span class="nav-text">ARP协议(地址解析协议)</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">邵俊颖</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">55</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">35</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/shaojunying" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;shaojunying" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:shaojunying1@gmail.com" title="E-Mail → mailto:shaojunying1@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://twitter.com/SHAOJY1999" title="Twitter → https:&#x2F;&#x2F;twitter.com&#x2F;SHAOJY1999" rel="noopener" target="_blank"><i class="fab fa-twitter fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://stackoverflow.com/users/10499946/shao-junying" title="StackOverflow → https:&#x2F;&#x2F;stackoverflow.com&#x2F;users&#x2F;10499946&#x2F;shao-junying" rel="noopener" target="_blank"><i class="fab fa-stack-overflow fa-fw"></i></a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">京ICP备2020041459号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">邵俊颖</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>

<script src="/js/bookmark.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>




  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
